package com.slaffka.mapper;

import com.slaffka.model._User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * Created by IntelliJ IDEA.
 * com.slaffka.mapper.UserMapper: v.tsapaev
 * Date: 10.02.12
 * Time: 18:57
 * To change this template use File | Settings | File Templates.
 */
public interface UserMapper {
    @Select(value = "SELECT * FROM public.user WHERE id = #{id}")
    _User getUserById(Long id);

    @Select(value = "SELECT * FROM public.user")
    List<_User> getUsers();

    @Insert(value = "INSERT INTO public.user (name, password) values (#{name}, #{password})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void addUser(_User user);
}
